<template>
  <div>
    <navbar></navbar>
    <img class="infoBgi" src="@/assets/default_bgi.png">
    <user-detail :userData="userData"></user-detail>
  </div>
</template>

<script>
import Navbar from '@/components/common/Navbar'
import UserDetail from '@/components/user/UserDetail'

export default {
  name: 'Userinfo',
  data () {
    return {
      userData: {}
    }
  },
  created () {
    this.getUserInfo()
  },
  methods: {
    // 获取用户个人信息
    async getUserInfo () {
      const res = await this.$http.get('/user/' + window.sessionStorage.getItem('id'))
      console.log(res)
      if (res.status === 200) {
        this.userData = res.data[0]
      } else {
        this.$msg.fail('用户信息获取失败')
      }
    }
  },
  components: {
    Navbar,
    UserDetail
  }
}
</script>

<style scoped>
.infoBgi {
  width: 100%;
}
</style>
